package com.atguigu.demo;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @Author 孔德成
 * @Slogan 致敬大师，致敬未来的你
 * @date 2021/8/9
 */
public class RunnableAndCallableDemo {
    public static void main(String[] args) {

        new Thread(new FutureTask<>(() -> {
            System.out.println(Thread.currentThread().getName() + "----come in");
            return "hello";
        })).start();
    }
}

class MyRunnable implements Runnable {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "----");
    }
}

class MyCallable implements Callable<String> {

    @Override
    public String call() throws Exception {
        System.out.println(Thread.currentThread().getName() + "----");
        return "Hello";
    }
}
